import { DtoValidation } from '@/modules/core/decorators/dto-validation.decorator';
import { Injectable } from '@nestjs/common';
import { Transform, Type } from 'class-transformer';
import {
  IsBoolean,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
} from 'class-validator';

@Injectable()
@DtoValidation({ type: 'body', groups: ['create'] })
export class CreateCartDto {
  @IsNumber()
  @Type(() => Number)
  num: number;

  @IsBoolean()
  @Type(() => Boolean)
  is_select: boolean;

  @IsString()
  @IsNotEmpty({ message: '物品不能为空', groups: ['create'] })
  @IsOptional({ groups: ['update'], always: true })
  good: string;
}
